#ifndef ZLH_STRINGUTIL_H
#define ZLH_STRINGUTIL_H

#include "StdHeader.h"

namespace egg {

    typedef vector<string> StringVector;

    class StringUtil {
    public:
        static void trim(string& str, bool left = true, bool right = true);
        static StringVector split(const string& str, const string& delims = "\t\n ", unsigned int maxSplits = 0);
        static StringVector tokenise(const string& str, const string& delims);
        static StringVector tokenise(const string& str, const string& dropDelims,const string& keepDelims);
        static void toLowerCase(string& str);
        static void toUpperCase(string& str);
        static bool startWith(const string& str, const string& pattern);
        static bool endsWith(const string& str, const string& pattern);
        static string standardisePath(const string &init);
        static void splitFullFilename(const string& qualifiedName,string& outBasename, string& outExtention,string& outPath);
        static void splitFileName(const string& fullName,string& baseName, string& extension);
        static bool match(const string& str, const string& pattern);
		static bool match(string& str,StringVector& strs);
        static const string replaceAll(const string& source, const string& replaceWhat, const string& replaceWithWhat);

        static string ptr2string(void* ptr){//get a unique string as name
            size_t value=(size_t)ptr;
            return toString<size_t>(value);
        }

        template<class T>
        static string toString(T value) {
            stringstream ss;
            ss << value;
            return ss.str();
        }

        template<class T>
        static T parseString(const string& str) {
            stringstream ss(str);
            T ret;
            ss >> ret;
            return ret;
        }
    };

}

#endif // _StringUtil_H__
